package com.example.singletask

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.singletask.util.Task
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class TaskTest {

    @Test
    fun create() {

        Task.singleTask {

        }.success {

        }.error {

        }.start()

    }

    fun process() {
        Task.progressTask<Int, Unit> { task ->
            var counter = 0
            while (task.isRunning) {
                Thread.sleep(1000)
                task.publishProgress(counter++)
            }
        }
    }

    fun timer() {
        Task.timerTask { counter, timestamp ->

        }.runOnThread().start()
    }
}